//
//  wodepingjiaViewController.m
//  个人信息
//
//  Created by IOSchengxuyuan on 15/12/8.
//  Copyright © 2015年 com.ppfur. All rights reserved.
//

#import "wodepingjiaViewController.h"

@interface wodepingjiaViewController (){
    float aa,bb;
    float width,height;
    UITableViewCell*cell;
    
}

@end

@implementation wodepingjiaViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _mytable.delegate=self;
    _mytable.dataSource=self;
    width=[UIScreen mainScreen].bounds.size.width;
    height=[UIScreen mainScreen].bounds.size.height;
    aa=width/320;
    bb=height/568;
    _mytable.frame=CGRectMake(0, 0, width, height);
    _mytable.scrollEnabled=NO;
    // Do any additional setup after loading the view.
}

//- (CGFloat)heightForContent:(NSString *)content
//{
//    //参数1.设置计算内容的宽高
//    //参数2.设置计算高度模式
//    //参数3.设置计算字体大小属性
//    //参数4.系统备用参数,设置为nil
//    //其中宽度一定与显示内容的label宽度一致,否则计算不准确
//    CGSize size = CGSizeMake(width - 30, 10000);
//    //字体大小一定与显示内容的label字体大小一致
//    NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:13.0] forKey:NSFontAttributeName];
//    CGRect frame = [content boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
//    return frame.size.height;
//}
+ (CGFloat)heightWithText:(NSString *)text
{
    CGRect rect = [text boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width / 3 * 2, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil];
    return rect.size.height;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row==0) {
        return 70;
    }else{
        return 60;
    }
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString*id=@"row";
    cell=[tableView dequeueReusableCellWithIdentifier:id];
    if(cell==nil)
    {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:id];
    }
    NSArray*row1=[cell.contentView subviews];
    //    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    for (UIView*vv2 in row1) {
        [vv2 removeFromSuperview];
    }
    if (indexPath.row==0) {
        UILabel*ll1=[[UILabel alloc]initWithFrame:CGRectMake(10*aa, 10, 50*aa, 30)];
        ll1.font=[UIFont systemFontOfSize:13.0f];
        ll1.text=@"杨健博";
        ll1.textColor=[UIColor lightGrayColor];
        [cell.contentView addSubview:ll1];
//        UILabel*ll2=[[UILabel alloc]initWithFrame:CGRectMake(260*aa, 10, 50*aa, 30)];
//        ll2.font=[UIFont systemFontOfSize:13.0f];
//        ll2.text=@"已处理";
//        ll2.textColor=[UIColor lightGrayColor];
//        [cell.contentView addSubview:ll2];
        UILabel*ll3=[[UILabel alloc]init];
        ll3.frame = CGRectMake(10*aa, 30, 220*aa, [[self class] heightWithText:ll3.text]);
        ll3.numberOfLines=0;
        ll3.font=[UIFont systemFontOfSize:12.0f];
        ll3.text=@"这个颜色的衣服很好看。服务态度好。物流快。下次还会来购买的。";
        ll3.textColor=[UIColor lightGrayColor];
        [ll3 sizeToFit];
        //        [ll3 setNumberOfLines:0];//设置自动行数与字符换行
        //         ll3.lineBreakMode = UILineBreakModeWordWrap; //测试字串
        //        NSString*ss=@"我的衣服尺码选择错误，我能调换一下么？我的衣服尺码选择错误，我能调换一下么？";
        //        CGSize size = CGSizeMake(220,200);
        [cell.contentView addSubview:ll3];
        UILabel*ll4=[[UILabel alloc]initWithFrame:CGRectMake(245*aa, 25, 80*aa, 30)];
        ll4.font=[UIFont systemFontOfSize:12.0f];
        ll4.text=@"2015-11-11";
        ll4.textColor=[UIColor lightGrayColor];
        [cell.contentView addSubview:ll4];
        
    }else{
        UILabel*ll1=[[UILabel alloc]initWithFrame:CGRectMake(10*aa, 10, 50*aa, 30)];
        ll1.font=[UIFont systemFontOfSize:13.0f];
        ll1.text=@"da**n";
        ll1.textColor=[UIColor lightGrayColor];
        [cell.contentView addSubview:ll1];
//        UILabel*ll2=[[UILabel alloc]initWithFrame:CGRectMake(260*aa, 10, 50*aa, 30)];
//        ll2.font=[UIFont systemFontOfSize:13.0f];
//        ll2.text=@"未处理";
//        ll2.textColor=[UIColor lightGrayColor];
//        [cell.contentView addSubview:ll2];
        UILabel*ll3=[[UILabel alloc]initWithFrame:CGRectMake(10*aa, 33, 220*aa, 30)];
        ll3.font=[UIFont systemFontOfSize:12.0f];
        ll3.text=@"衣服尺码选择错误，要求调换衣服尺码。";
        ll3.textColor=[UIColor lightGrayColor];
        [cell.contentView addSubview:ll3];
        UILabel*ll4=[[UILabel alloc]initWithFrame:CGRectMake(245*aa, 25, 80*aa, 30)];
        ll4.font=[UIFont systemFontOfSize:12.0f];
        ll4.text=@"2015-11-11";
        ll4.textColor=[UIColor lightGrayColor];
        [cell.contentView addSubview:ll4];
        
    }
    
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}
/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
